const { spawn } = require('child_process')

function runGit(str, arr) {

    return new Promise((resolve => {
        const handle = spawn(str, arr);
        let res = ''

        handle.stdout.on("data", function (data) {
            res += data.toString()
        })

        handle.stderr.on("end", function () {
            resolve(res)
        })
    }))

}

const commands = [
    ['git', ['branch']],
    ['git', ['log', '--pretty=format:"%H - %an - %cd"', "--date=iso8601"]],
]

async function getVersion() {
    for (const command of commands) {
        let res = await runGit.apply(undefined, command)
        console.log(res)
    }
}


getVersion()
